package com.jason.quectel0805.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import androidx.annotation.Nullable;

/**
 * @author：Jason
 * @date：2022/8/8 10:49
 * @email：1129847330@qq.com
 * @description:
 */
public class MyService extends Service {
    private static final String TAG = "jasonwan";

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        String download_url = intent.getStringExtra("download_url");
        //进行下载操作
        Log.d(TAG, "onStartCommand: download_url=" + download_url);
        //在低版本的Android系统当中，当app进程被系统杀死时，进程中的所有service、线程以及其他组件都会被
        // 销毁，而使用此返回值会使当前Service原地复活
        return START_STICKY;
        //
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "onCreate: service被成功启动了,当前线程：" + Thread.currentThread().getName());
        new Thread(new Runnable() {
            @Override
            public void run() {
                Log.d(TAG, "run: " + Thread.currentThread().getName());
            }
        }).start();

    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }
}